package test;

import org.administer.dao.*;
import org.administer.pojo.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.text.SimpleDateFormat;
import java.util.*;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:aop.xml")
public class test {
    @Autowired
    private CrmPermissionDao permissionDao;
    @Autowired
    private CrmUserDao crmUserDao;
    @Autowired
    private CrmDictionariesDao crmDictionariesDao;
    @Autowired
    private CrmServiceDao crmServiceDao;
    @Autowired
    private CrmShoppingDao crmShoppingDao;
    @Autowired
    private CrmCustomerDao crmCustomerDao;
    @Autowired
    private CrmPermissionDao crmPermissionDao;
    @Autowired
    private CrmjiluDao crmjiluDao;
    @Autowired
    private ChatDao chatDao;
    @Autowired
    private CrmOrderDao crmOrderDao;
    @Test
    public void getPersByUserId(){
       List<CrmPermission> list= permissionDao.getPersByUserId(1);
        for (CrmPermission crmPermission:
             list) {
            System.out.println(crmPermission.getName());
        }
    }
    @Test
    public void getde(){
        List<CrmService> crmService=crmServiceDao.getlist(null);
        for (CrmService c :
                crmService) {
            System.out.println(c.getClientele());

            System.out.println("\t"+c.getDictionariesid().getName());
        }
    }
    @Test
    public void service(){
        List<CrmService> list=crmServiceDao.getlistguidang(null);
        for (CrmService c :list) {
            System.out.println(c.getFenpei().getUsername());
            System.out.println(c.getUserid());

        }
    }
    @Test
    public void aaa(){
        CrmUser crmUser=new CrmUser();
        crmUser.setId(1);
        List<CrmUser> list=crmUserDao.getlist(crmUser);
        for (CrmUser c :list) {
            System.out.println(c.getUsername());
            System.out.println(c.getRoleString());
        }
    }
    @Test
    public void shopping(){
       List<CrmShopping> list=crmShoppingDao.getlist(null);
        for (CrmShopping c :
                list) {
            System.out.println(c.getCrmStore().getStorename());
        }
    }
    @Test
    public void getlist(){
        CrmCustomers crmCustomers=new CrmCustomers();
        crmCustomers.setUserId(1);
        List<CrmCustomers> list=crmCustomerDao.getlist(crmCustomers);
        for (CrmCustomers c :
                list) {
            System.out.println(c.getCustName());
        }
    }
    @Test
    public  void getaaa(){
        CrmUser crmUser=new CrmUser();
        List<CrmPermission> list = crmPermissionDao.getPersByUserId(1);
        Set<String> set = new HashSet<>();
        for (CrmPermission per :
                list) {
            set.add(per.getPercode());
            System.out.println(per.getPercode());
        }
    }
    @Test
    public  void  qwe(){
        CrmService aa=new CrmService();
        aa.setUserid(2);
        List<CrmService> list=crmServiceDao.getlist(aa);
        for (CrmService c :
                list) {
//            System.out.println(c.getId());
//            System.out.println(c.getUserid());
//            System.out.println(c.getClientele());
            System.out.println(c.getTypeid());
        }
    }
    @Test
    public void aaabv(){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        String time=sdf.format(new Date());
        System.out.println(time);
    }
    @Test
    public void getadsa(){
        CrmJilu crmJilu=new CrmJilu();
        crmJilu.setCutid("WZ010804");
        crmJilu.setCutname("陈毅");
        List<CrmJilu> li=crmjiluDao.getlist(crmJilu);
        for (CrmJilu c :
                li) {
            System.out.println(c.getOntline());
        }
    }
    @Test
    public void asdasdasd(){
//        CrmChat c =chatDao.get(3);
//        System.out.println(c.getNeirong());
        int min = 1000000;
        int max = 9999999;
        for(int i=0;i<1;i++){
           int aa= new Random().nextInt(max-min)+min;
            System.out.println(Integer.toString(aa));
        }
    }
    @Test
    public  void      aaaaaaaa(){
      CrmOrder crmOrder=new CrmOrder();
      crmOrder.setCusno("大");
       List<CrmOrder> list= crmOrderDao.getchaxun(crmOrder);
        for (CrmOrder c :
                list) {
            System.out.println(c.getCrmCustomers().getCustName());
        }
    }
}
